package file1;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;

public class Demo8 {
    public static void main(String[] args) {
        try (InputStream inputStream = new FileInputStream("test.txt")) {
            // 读文件
            byte[] b = new byte[1024];
            int len = inputStream.read(b);
            for (int i = 0; i < len; i++) {
                System.out.println(b[i]);
            }
            // .............
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void main1(String[] args) throws FileNotFoundException {
        InputStream inputStream = new FileInputStream("test.txt");
        //从文件输入流中读取数据
        Scanner scanner=new Scanner(inputStream);
        while(scanner.hasNext()){
            String s=scanner.next();
            System.out.println(s);
        }


    }
}
